<template>
  <div class="home-banner">
    <XtxSlider :data="banners" autoPlay />
  </div>
</template>

<script>
import { findBannerApi } from '@/api/home'
import { onMounted, ref } from 'vue'
export default {
  name: 'HomeBanner',
  setup () {
    // 2.定义变量：存储轮播图数据
    const banners = ref([])
    // 1.定义方法：获取轮播图数据
    const getBanner = async () => {
      const { data } = await findBannerApi()
      console.log('轮播图数据:', data)
      banners.value = data
    }
    onMounted(() => {
      getBanner()
    })
    return { banners }
  }
}
</script>

<style scoped lang='less'>
.home-banner {
  width: 1240px;
  height: 500px;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 98;
}
</style>
